package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.StackProblem;

import java.util.LinkedList;

/**
 * 两个栈模拟队列, 两个队列模拟栈
 * 225 232
 *
 * @author tzp
 * @since 2020/11/18
 */
public class LC232 implements StackProblem {
    class MyQueue {
        LinkedList<Integer> stack0;
        LinkedList<Integer> stackTemp;
        public MyQueue() {
            stack0 = new LinkedList<>();
            stackTemp = new LinkedList<>();
//            .offerLast();
//            .removeLast();
//            .peekLast();
        }


        public void push(int x) {
            while (stack0.size() > 0) {
                stackTemp.offerLast(stack0.removeLast());
            }
            stack0.offerLast(x);
            while (stackTemp.size() > 0) {
                stack0.offerLast(stackTemp.removeLast());
            }
        }

        public int pop() {
            return stack0.removeLast();
        }

        public int peek() {
            return stack0.getLast();
        }

        public boolean empty() {
            return stack0.size() == 0 ;
        }
    }

    public static void main(String[] args) {
        System.out.println(new LC232());
    }
}
